package arch.dao.impl.user;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import arch.domain.user.relation.UserDept;
/**
 * 
 * @author ZhaoWangLong Sep 11, 2012
 *
 */
public class UserDeptBatchInsertSetter implements BatchPreparedStatementSetter {
	private List<UserDept> userDepts;
	
	public UserDeptBatchInsertSetter(List<UserDept> userDepts){
		this.userDepts = userDepts;
	}
	
	public int getBatchSize() {
		return userDepts.size();
	}

	public void setValues(PreparedStatement ps, int i) throws SQLException {
		ps.setString(1, userDepts.get(i).getDept().getDeptId());
		ps.setString(2, userDepts.get(i).getUser().getUserId());
		ps.setInt(3, userDepts.get(i).getIndex());
	}

}
